package com.hrsystem.service;

import com.hrsystem.entity.News;
import com.hrsystem.entity.PersonalData;
import com.hrsystem.mapper.NewsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class NewsService {
    @Autowired
    private NewsMapper newsMapper;

    /**
     * 根据管理员id查出所有的资讯
     * @param adminId
     * @return
     */
    public List<News> getListAll(Integer adminId) {
        List<News> getListAll = newsMapper.getListAll(adminId);
        if (adminId != null) {
            System.out.println(adminId);
            return getListAll;
        }
        return null;
    }

    /**
     * 添加资讯
     * @param news
     * @return
     */
    public News getIntoNews(News news) {
        boolean isSuccess = newsMapper.getIntoNews(news) > 0;
        System.out.println("插入一条数据，ID是：" + news.getId());
        if (isSuccess) {
            return news;
        } else {
            return null;
        }
    }

}
